package com.design.movieticket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.design.movieticket.dto.OrdersDto;
import com.design.movieticket.entity.Orders;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrdersMapper extends BaseMapper<Orders> {
    /** 小程序查询尚未使用订单 */
    @Select("SELECT a.id,a.seat_select,a.order_number,a.order_pay,b.start_time,b.end_time,c.id as movieId,c.movie_name,c.still,d.cinema_name,d.address\n" +
            "FROM orders a\n" +
            "LEFT JOIN movie_arrange b\n" +
            "on a.movie_arrange_id = b.id\n" +
            "LEFT JOIN movie c\n" +
            "on c.movie_name = b.movie_name\n" +
            "left join cinema d\n" +
            "on d.id = a.cinema_id\n" +
            "where b.end_time > #{nowTime} and a.username = #{username}")
    List<OrdersDto> wxGetOrdersByUserName(String username,String nowTime);

    /** 小程序查询已看订单 */
    @Select("SELECT a.id,a.seat_select,a.order_number,a.order_pay,b.start_time,b.end_time,c.id as movieId,c.movie_name,c.still,d.cinema_name,d.address\n" +
            "FROM orders a\n" +
            "LEFT JOIN movie_arrange b\n" +
            "on a.movie_arrange_id = b.id\n" +
            "LEFT JOIN movie c\n" +
            "on c.movie_name = b.movie_name\n" +
            "left join cinema d\n" +
            "on d.id = a.cinema_id\n" +
            "where b.end_time < #{nowTime} and a.username = #{username}")
    List<OrdersDto> wxGetHadBeenMovieByUserName(String username,String nowTime);
}
